package com.qf.controller;



import com.qf.pojo.BaseResp;
import com.qf.service.ShopCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/shopCart")
public class ShopCartController {
    @Autowired
    ShopCartService shopCartService;

    //添加购物车
    @RequestMapping("/add")
    public BaseResp add(@RequestBody Map map, HttpServletRequest request){
        return shopCartService.add(map,request);
    }
    //查询购物车
    @RequestMapping("/findShopCart")
    public BaseResp findAll(HttpServletRequest request){
        return shopCartService.findAll(request);
    }

    //添加一条购物车信息
    @RequestMapping("/addShopCart")
    public BaseResp addShopCart(@RequestBody Map map, HttpServletRequest request){
        return shopCartService.addShopCart(map,request);
    }
    //删除一条购物车信息
    @RequestMapping("/deletShopCart")
    public BaseResp deletShopCart(@RequestBody Map map,HttpServletRequest request){
        return shopCartService.deletShopCart(Integer.valueOf(map.get("sid").toString()),request);
    }
    //提交购物车
    @RequestMapping("/submit")
    public BaseResp submit(@RequestBody Map map,HttpServletRequest request){

        return shopCartService.submit(map,request);
    }
}
